package com.es.designmode.state;

/**
 * @author Will
 */
public class Context {

    private State state;

    public Context(State state) {
        this.state = state;
    }

    public State getState() {
        System.out.println("当前状态：" + state);
        return state;
    }

    public void setState(State state) {
        System.out.println("设置当前状态：" + state);
        this.state = state;
    }

    /**
     * 对请求做处理，并设置下一个状态
     */
    public void request() {
        state.handle(this);
    }
}
